/*
 *  SimulationParam.cpp
 *  Milovo03epsilon03
 *
 *  Created by luca on 04/08/06.
 *  Copyright 2006 __MyCompanyName__. All rights reserved.
 *
 */

#include "SimulationParam.h"

SimulationParams::SimulationParams()
{
	WorkingDir = "empty_var";
	NewSimulation = 1;
	NumFirstStep = 1;
	NumLastStep = 1;
}

SimulationParams::SimulationParams(string tmpWorkingDir, string tmpPathMilinitConf, string tmpPathMilovoParamConf, string tmpPathEventsTable, 
											  Mil_Int tmpNewSimulation, Mil_Int tmpNumFirstStep, Mil_Int tmpNumLastStep)
{
	WorkingDir = tmpWorkingDir;
	PathMilinitConf = tmpPathMilinitConf;
	PathMilovoParamConf = tmpPathMilovoParamConf;
	PathEventsTable = tmpPathEventsTable;
	NewSimulation = tmpNewSimulation;
	NumFirstStep = tmpNumFirstStep;
	NumLastStep = tmpNumLastStep;
}

SimulationParams::~SimulationParams()
{
}

void SimulationParams::LoadSimulationParam(string strPath)
{
	WorkingDir = strPath;
	string tmpFileInitnetParam = WorkingDir + "SimulaParam.conf";
	ifstream in(tmpFileInitnetParam.c_str());
	
	string tmpSingleParam;
	while(getline(in, tmpSingleParam))
	{
		Mil_Int tmpEqualPos;
		if(tmpSingleParam.find("#"))
		{
			tmpEqualPos = tmpSingleParam.find("=");
			string tmpNameSingleParam(tmpSingleParam, 0, tmpEqualPos);
			string tmpValueSingleParam(tmpSingleParam, tmpEqualPos + 1, tmpSingleParam.size());
			if(tmpNameSingleParam == "NewSimulation") NewSimulation = atol(tmpValueSingleParam.c_str());
			if(tmpNameSingleParam == "NumFirstStep") NumFirstStep = atol(tmpValueSingleParam.c_str());
			if(tmpNameSingleParam == "NumLastStep") NumLastStep = atol(tmpValueSingleParam.c_str());
		}
	}
	
	PathMilinitConf = WorkingDir + "Milinit.conf";
	cout << "Milinit -> " << PathMilinitConf << endl;
	PathMilovoParamConf = WorkingDir + "MilovoParam.conf";
	cout << "MilovoParam -> " << PathMilovoParamConf << endl;
	PathEventsTable = WorkingDir + "MilovoEvents.csv";
	cout << "MilovoEvents -> " << PathEventsTable << endl;
}

void SimulationParams::PrintSimulationParam()
{
	cout << " -- BEGIN PRINT SIMULATION PARAMETERS -- " << endl;
	cout << "NewSimulation : " << NewSimulation << endl;
	cout << "PathMilinitConf : " << PathMilinitConf << endl;
	cout << "PathMilovoParamConf : " << PathMilovoParamConf << endl;
	cout << "NumFirstStep : " << NumFirstStep << endl;
	cout << "NumLastStep : " << NumLastStep << endl;
	cout << " -- END PRINT SIMULATION PARAMETERS -- " << endl;
}


